package com.hxx.day4;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.junit.Test;

import java.util.*;

public class TestDemo{
    @Test
    public void test1() {
        List<Integer> list = List.of(1, 2, 3);
        for (int index = 0; index < list.size(); index++) {
            System.out.println(list.get(index));
        }
        for (Integer integer : list) {
            System.out.println(integer);
        }
        list.forEach(System.out::println);
        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
    @Test
    public void test2() {
        List list = new ArrayList();
        list.add(1);
        list.add("hello");
        list.add(3);

        List<Integer> list1 = List.of(1, 2, 3);
        list.addAll(list1);
        System.out.println(list);
    }

    /**
     * https://gitee.com/xiudun/hxxjavase1
     */
    @Test
    public void test3() {
        List.of(1, 2, 3);
        Set set = new HashSet();
        set.add(1001);
        set.add(100003);
        set.add(10);

        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        System.out.println(set.contains(10));
        System.out.println(set.isEmpty());

        for (int index = 0; index < set.toArray().length; index++) {
            System.out.println(set.toArray()[index]);
        }

        /*for (Object o : set) {
            System.out.println(o);
        }*/
    }
}
